package controllers

import (
	"github.com/astaxie/beego"
	"video/models"
)

type MainController struct {
	beego.Controller
}

func (c *MainController) Get() {
	c.TplName = "index.tpl"

	// 获取菜单数据
	var datalist []models.HomeMenu
	datalist, err := models.GetMenu()
	if err != nil {
		beego.Error(err)
	}
	c.Data["Menu"] = datalist

	// 获取热门影片
	var popularWithData []models.PopularWith
	popularWithData,err = models.GetPopularWith()
	if err != nil {
		beego.Error(err)
	}
	c.Data["PopularWithData"] = popularWithData

	// 获取最新影片
	var newVideoData []models.NewVideo
	newVideoData,err = models.GetNewVideo()
	if err != nil {
		beego.Error(err)
	}
	c.Data["NewVideoData"] = newVideoData

	// 获取最高分影片
	var maxVideoData []models.MaxScore
	maxVideoData,err = models.GetMaxScore()
	if err != nil {
		beego.Error(err)
	}
	c.Data["MaxVideoData"] = maxVideoData

}
